package domd7;
class login{
    private String userName="root";
    private String password="1234";

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void logInfo(String userName, String password) {
        if (!this.userName.equals(userName)) {
            throw new UserNameException("用户名错误");
        }
        if (!this.password.equals(password)) {
           throw new UserNameException("密码错误");
        }
        System.out.println("登陆成功");
    }
}
public class test {
    public static void main(String[] args) {
        login login=new login();
        try{
            login.logInfo("ABC","123");
        }catch (UserNameException e)
        {
            System.out.println("捕获了UserNameException...");
            e.printStackTrace();
        }finally {
            System.out.println("finally,,,");
        }
    }
}
